package com.xlj.springbootmybatis.user.mapper;

import com.xlj.springbootmybatis.user.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: xlj
 * @Description:
 * @Date: Created in 13:52 2019\2\1 0001
 */
@Repository
public interface UserMapper {

    User getUserById(Integer userId);

    int addUser(User user);

    int delUserByUserId(Integer userId);

    /**
     * 注：如果使用@Param注解来声明参数时，使用 #{} 或 ${} 的方式都可以
     *    若不使用@Param注解来声明参数，则只能使用#{}
     */
    //@Select("SELECT * FROM USER WHERE user_name like CONCAT('%',${userName},'%')")
    @Select("SELECT * FROM USER WHERE user_name like CONCAT('%',#{userName},'%')")
    List<User> getUserByUserName(@Param("userName") String userName);

    List<User> getUserList(User user);

    int updateUserByUserId(@Param("user") User user);
}
